/*
 * @Author: wuqingchun
 * @Date: 2024-10-18 21:20:18
 * @Description: 
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-10-21 10:28:30
 */
#ifndef __NET_BUFFER_H__
#define __NET_BUFFER_H__

#include <cstdint>
#include <list>

typedef struct BufferItem
{
    char* pcStart;
    char* pcData;
    size_t ulSize;
    size_t ulDataLen;
}BUFFER_ITEM_S;

class CNetBuffer
{
public:
    int32_t Init(size_t ulBufLen);
    int32_t AddData(const void* pData, size_t ulDataLen);
    bool GetItem(BUFFER_ITEM_S& refItem);
    void PushBack(BUFFER_ITEM_S& refItem);
    void Free(BUFFER_ITEM_S& refItem);

    bool Empty();
private:
    std::list<BUFFER_ITEM_S> m_objFreeList;
    std::list<BUFFER_ITEM_S> m_objUsedList;
};

#endif //__NET_BUFFER_H__